package exception;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author げっしょく
 * @date 2021/7/24
 */
public class Test2 {
    public static void main(String[] args) {
        //metho();
        String s = "2001-02-20";
        try{
            Date date = metho2(s);
            System.out.println(date);
        }catch (ParseException p){
            System.out.println("解析格式错误！！！");
        }

    }

    private static Date metho2(String s) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return simpleDateFormat.parse(s);
    }

    private static void metho() throws ParseException {
        String s = "2021-02-20";
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = dateFormat.parse(s);
        System.out.println(parse);
    }
}
